from dto.train_lineDTO import TrainLineDTO
from dao.traindatadao import TrainDataDao
from dao.evaluationdao import EvaluationDao
from dao.model_describedaao import ModelDescribeDao
class TrainListService:
    tDao = TrainDataDao()
    eDao = EvaluationDao()
    mDao = ModelDescribeDao()
    def get_train_list(self):
        train_list = []
        train_ids = self.tDao.getAllIId()
        for id in train_ids:
            id =id[0]
            acc = self.eDao.getMaxAccByTrainId(id)
            model_type = self.mDao.findModelTypeByTrainId(id)
            line = TrainLineDTO()
            train_data = self.tDao.findById(id)
            line.accuracy = acc
            line.model_type = model_type
            line.decay = train_data.decay
            line.image_width = train_data.image_width
            line.image_height = train_data.image_height
            line.epoch_acc_img_name = train_data.epoch_acc_img_name
            line.learning_rate = train_data.learning_rate
            line.count_epoch = train_data.count_epoch
            line.train_id = train_data.id
            train_list.append(line)

        return train_list
if __name__ == "__main__":
    print(TrainListService().get_train_list())